home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Pascal / SWar / Stars.p < prev    next >
Text File  |  1995-06-15  |  855b  |  43 lines

  1. unit stars;
  2.  
  3. interface
  4.     uses
  5. {$IFC UNDEFINED THINK_PASCAL}
  6.         Types, QuickDraw, Events, Menus, Dialogs, Fonts, Resources, Devices,
  7. {$ENDC}
  8.         Globals, Util;
  9.  
  10.     procedure InitStars;
  11.     procedure DrawStars;
  12.  
  13. implementation
  14.  
  15.     procedure InitStars;
  16.         var
  17.             i: Integer;
  18.     begin
  19.         for i := 0 to MAX_STARS - 1 do
  20.             begin
  21.                 gStarRecs[i].where.v := RngRnd(0, 479);
  22.                 gStarRecs[i].where.h := RngRnd(0, 639);
  23.                 gStarRecs[i].color.red := -1;
  24.                 gStarRecs[i].color.green := -1;
  25.                 gStarRecs[i].color.blue := -1;
  26.             end; (* for *)
  27.     end; (* InitStars() *)
  28.  
  29.     procedure DrawStars;
  30.         var
  31.             i: Integer;
  32.             savePort: GrafPtr;
  33.     begin
  34.         GetPort(savePort);
  35.         SetPort(GrafPtr(gOSPtr));
  36.         for i := 0 to MAX_STARS - 1 do
  37.             begin
  38.                 SetCPixel(gStarRecs[i].where.h, gStarRecs[i].where.v, gStarRecs[i].color);
  39.             end; (* for *)
  40.         SetPort(savePort);
  41.     end; (* DrawStars() *)
  42.  
  43. end.